package com.neu.canteen.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neu.canteen.service.BookService;
import com.neu.canteen.service.impl.BookServiceImpl;

public class BookController extends HttpServlet{
	
	private BookService bookService = new BookServiceImpl();
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		String customerId = req.getParameter("customerId");
		String foodId [] = req.getParameterValues("foodId");
		String count [] = req.getParameterValues("count");
		
		
		int [] foodIntId=new int[foodId.length];
		int [] countInt=new int[count.length];
		
		for(int i=0;i<foodId.length;i++){
			
			foodIntId[i]=Integer.parseInt(foodId[i]);
			countInt[i]=Integer.parseInt(count[i]);
		}
		
		
		bookService.createBook(Integer.parseInt(customerId), foodIntId, countInt);
	}

}
